package excercise.Page28;

/**
 * @Author: Miyako
 * @Date: 2024-07-15-9:19
 * @Description:正三角形
 */
public class Triangle extends Shape{
    Triangle(){

    }
    Triangle(double y){
        setX(y);
        setY(y);
    }
    @Override
    void print() {
        for (int y =0;y<getY();y++) {
            for (int x = 0 ;x<=y;x++){
                System.out.print("* ");
            }
            System.out.println();
        }

    }

    @Override
    double area() {
        return super.area=getX()*getY()/2;
    }
/**
 * 直角三角形周长
 *
 */
    @Override
    double perimeter() {//
        double biasLine2 = getX()*getX()+getY()*getY();
         double biasLine = Math.sqrt(biasLine2);//斜边长
         return super.perimeter = getX()+getY()+biasLine;//三边相加

    }
}
